//
//  ForgetPswViewController.m
//  easystudy
//
//  Created by 陈彦超 on 16/8/31.
//  Copyright © 2016年 kane. All rights reserved.
//

#import "ForgetPswViewController.h"
#import "AuthCodeView.h"
#import "ModifyPasswordController.h"

@interface ForgetPswViewController ()
{
    __weak IBOutlet UILabel *accountLbl;
    __weak IBOutlet AuthCodeView *authView;
    __weak IBOutlet UIButton *commitBtn;
}

@end

@implementation ForgetPswViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    self.title = @"忘记密码";
    
    UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"image_backBtn"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtn)];
    self.navigationItem.leftBarButtonItem = leftBtn;
    
    
    [authView getAuthcode];
    _phoneTF.text = [UserEntity sharedUser].MobilePhone;
    _phoneTF.userInteractionEnabled = _phoneTF.text.length == 0;
    [_phoneView drawCornerRadius:5];
    [_phoneView drawBorderColor:[UIColor lightGrayColor] Width:1];
    
    [_codeView drawCornerRadius:5];
    [_codeView drawBorderColor:[UIColor lightGrayColor] Width:1];
    [commitBtn drawCornerRadius:5];
}

- (void)backBtn
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)commitBtnPressed:(id)sender
{
    ModifyPasswordController *modifyVC = [[ModifyPasswordController alloc] init];
    [self.navigationController pushViewController:modifyVC animated:YES];
}

//手机/邮箱切换
- (IBAction)segmentedClick:(UISegmentedControl *)sender
{
    switch (sender.selectedSegmentIndex) {
        case 0:
        {
            accountLbl.text = @"手机号";
            _phoneTF.placeholder = @"请输入手机号";
        }
            break;
        case 1:
        {
            accountLbl.text = @"邮箱";
            _phoneTF.placeholder = @"请输入邮箱";
        }
            break;
            
        default:
            break;
    }
}

//隐藏键盘
- (void)hideKeyboard
{
    [_phoneTF resignFirstResponder];
    [_codeTF resignFirstResponder];
}

//隐藏键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self hideKeyboard];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
